using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class VLifeCore_Dog : VLifeCore
{
    public VActBehaviour actBehaviour;
    private LLMIP_DogTalk curHandler;
    public string DoingAction;
    public string LastAction;

    public Dictionary<string, TriggerObserver> actions;
    public void Start()
    {
        actBehaviour = gameObject.UniqueComponent<VActBehaviour>();
        actions = new Dictionary<string, TriggerObserver>();
        var mvm = GetComponent<VActProcessor>().mvm;
        actions["FreeToPlay"] = new TriggerObserver()
        {
            start = () =>
            {
                print("那我玩去啦");
                if (mvm.RandomSampleOnNavMesh(out var point))
                {
                    actBehaviour.WalkToPoint(point);
                }
                else
                {
                    throw new System.Exception("找不到导航点,检查网格和层级!");
                }

            }
        };

        actions["GoToSecondFloor"] = new TriggerObserver()
        {
            start = () =>
            {
                var pos = GameObject.Find("SecondFloor");
                actBehaviour.WalkToPoint(pos.transform.position);
            }
        };
        actions["GoToGate"] = new TriggerObserver()
        {
            start = () =>
            {
                var pos = GameObject.Find("Gate");
                actBehaviour.WalkToPoint(pos.transform.position);
            }
        };

        actions["ComeBack"] = new TriggerObserver()
        {
            start = actBehaviour.ComeBack
        };

        actions["Happy"] = new TriggerObserver()
        {
            start = () => actBehaviour.Show("Happy", true)
        };

        actions["SitDown"] = new TriggerObserver()
        {
            start = () => actBehaviour.Show("SitDown", false)
        };

        actions["StandUp"] = new TriggerObserver()
        {
            start = () => actBehaviour.Show("StandUp", false)
        };

    }
    public void UserTalk(string context)
    {
        curHandler = new LLMIP_DogTalk(this, context, ",", ",", actions.ToKeysString());
        curHandler.onResponse = (str) =>
        {
            if (actions.ContainsKey(str))
            {
                actions[str].Subscribe();
            }
        };
        curHandler.Generate();
    }



}
